namespace IAM.Interface.Common.XMLResolution
{
    using IAM.Interface.Model.ENUM;
    using System;
    using System.Xml;

    public class XMLResolutionMgnt
    {
        private IAM.Interface.Model.ENUM.ActionType _actiontype;
        private IAM.Interface.Model.ENUM.OperationType _operationtype;
        private string _transactionid;
        private System.Xml.XmlDocument _xmldocument;

        public XMLResolutionMgnt(string xml)
        {
            this._actiontype = IAM.Interface.Model.ENUM.ActionType.Nullity;
            this._operationtype = IAM.Interface.Model.ENUM.OperationType.Nullity;
            this._transactionid = "";
            this._xmldocument = new System.Xml.XmlDocument();
            this._xmldocument.LoadXml(xml);
        }

        public XMLResolutionMgnt(System.Xml.XmlDocument xd)
        {
            this._actiontype = IAM.Interface.Model.ENUM.ActionType.Nullity;
            this._operationtype = IAM.Interface.Model.ENUM.OperationType.Nullity;
            this._transactionid = "";
            this._xmldocument = xd;
        }

        public XMLResolutionMgnt(string xml, string transactionid)
        {
            this._actiontype = IAM.Interface.Model.ENUM.ActionType.Nullity;
            this._operationtype = IAM.Interface.Model.ENUM.OperationType.Nullity;
            this._transactionid = "";
            this._xmldocument = new System.Xml.XmlDocument();
            this._xmldocument.LoadXml(xml);
        }

        public AbstractXMLResolution CreateXMLResolution()
        {
            AbstractXMLResolution axr = null;
            XmlElement xe = this.XmlDocument.DocumentElement;
            switch (xe.Name.ToLower())
            {
                case "requestdata":
                    axr = new Request();
                    axr.XmlDocument = this.XmlDocument;
                    return axr;

                case "responsedata":
                    axr = new Response(this.ActionType);
                    axr.XmlDocument = this.XmlDocument;
                    return axr;
            }
            axr = new Request();
            axr.XmlDocument = this.XmlDocument;
            return axr;
        }

        public IAM.Interface.Model.ENUM.ActionType ActionType
        {
            get
            {
                return this._actiontype;
            }
            set
            {
                this._actiontype = value;
            }
        }

        public IAM.Interface.Model.ENUM.OperationType OperationType
        {
            get
            {
                return this._operationtype;
            }
            set
            {
                this._operationtype = value;
            }
        }

        public string TransactionID
        {
            get
            {
                return this._transactionid;
            }
            set
            {
                this._transactionid = value;
            }
        }

        public System.Xml.XmlDocument XmlDocument
        {
            get
            {
                return this._xmldocument;
            }
            set
            {
                this._xmldocument = value;
            }
        }
    }
}

